<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>会员注册_中国根雕行业网</title>
     <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
    <link href="../css/regist.css" type="text/css" rel="stylesheet">
    <link href="../css/style.css" type="text/css" rel="stylesheet">
</head>
<body>

<!--头部-->
<div class="top">
    <div class="top_box">
        <div class="top_box_left">
            <div class="black fw_b fs_12">欢迎光临中国根雕行业网</div>
        </div>
    </div>
</div>

<div class="content">
    <div class="content_top">
        <div class="logo" align="center">
            <img src="../img/logo.png" alt="中国根雕行业网">
        </div>

        <div class="tittle">
            会员注册
        </div>
    </div>
</div>

<div class="line">
</div>


<div class="information bor">
    <img src="../regist/re.jpg" alt="填写账户信息">

    <div class="info_box">
        <h3>账户信息</h3>

        <div class="info">
            <div class="info_left">
                <span class="info_tit">会员类型</span>
            </div>
            <div class="info_right">
                <input type="radio" name="member" id="per" checked="checked" value="0"><label for="per">个人会员</label>&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="member" id="com" value="1"><label for="com">企业会员</label>
            </div>
        </div>

        <div class="info">
            <div class="info_left">
                <span class="info_tit">用户名</span>
            </div>
            <div class="info_right">
                <input type="text" class="info_in" id="userName" onblur="checkName()">
            </div>
        </div>
        <div class="info">
            <div class="info_left">
                <span class="info_tit">邮箱</span>
            </div>
            <div class="info_right">
                <input type="text" class="info_in" id="userMail" onblur="checkMail()">
            </div>
        </div>
        <div class="info">
            <div class="info_left">
                <span class="info_tit">密码</span>
            </div>
            <div class="info_right">
                <input type="password" class="info_in" id="userPwd" onblur="checkPwd()">
            </div>
        </div>
        <div class="info">
            <div class="info_left">
                <span class="info_tit">确认密码</span>
            </div>
            <div class="info_right">
                <input type="password" class="info_in" id="againPwd" onblur="checkApwd()">
            </div>
        </div>

        <div class="bu white" onclick="userRegist()">确认提交</div>
    </div>
</div>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
    var memberVal;
    var userName;
    var userMail;
    var userPwd;
    var againPwd;
    //用户名正则
    var de_name = /^[\u4e00-\u9fa5]{0,}$/;
    //    邮箱正则
    var de_mail = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
//    密码正则
    var de_pwd = /^[A-Za-z0-9]+$/;
    //    检验用户名
    function checkName() {
        userName = $.trim($("#userName").val());
        if (userName == "" || de_name.test(userName) == false || userName.length < 2 || userName.length > 8) {
            alert("用户名只能由2至8位汉字组成");
            return 2;
        } else {
            return 1;
        }
    }
    //   检验邮箱
    function checkMail() {
        userMail = $.trim($("#userMail").val());
       if ( userMail!=""&&de_mail.test(userMail) == false) {
            alert("请检查邮箱格式");
            return 2;
        }else{
            return 1;
        }
    }
//    检验密码
    function checkPwd(){
        userPwd = $.trim($("#userPwd").val());
       if ( userPwd!=""&&de_pwd.test(userPwd) == false) {
            alert("密码只能由字母和数字组成");
            return 2;
        }else{
            return 1;
        }
    }
//    检验二次密码
    function checkApwd(){
        userPwd = $.trim($("#userPwd").val());
        againPwd = $.trim($("#againPwd").val());
       if (againPwd!=""&& userPwd!=againPwd){
            alert("两次密码不一致");
            return 2;
        }else{
            return 1;
        }
    }

    //用户注册账号
    function userRegist() {
//            获取会员类型
        
        userType = $('input:radio[name="member"]:checked').val();
        userNo = $.trim($("#userName").val());
        email = $.trim($("#userMail").val());
        loginPassword = $.trim($("#againPwd").val());
        userPwd = $.trim($("#userPwd").val());
         var json = {"userInfo":{"userType":userType,"userNo":userNo,"email":email,"loginPassword":loginPassword},"userType":1} 
        if (userType == "" || userNo == "" || email == "" || userPwd == "" || againPwd == "") {
            alert("请完善所有信息")
        }else if(checkMail()+checkName()+checkPwd()+checkApwd()!=4){
            alert("信息有误，请核对确认")
        }else if(userType=="0"){
//             $.ajax({
//                 type:"POST",
<%--                 url:"<%=basePath%>User/registOne", --%>
//                 dataType:"json",
//                 data:'registryParam='+'{userInfo:{userType:'+userType+',userNo:'+userNo+',email:'+email+',loginPassword:'+'loginPassword},userType:'+userType+'}',
//                 success:function(result){
//                     if(result.code=="1"){
//                     	 window.location.href="per_info.html+";
//                     }else{
                       
// //                    alert(result.randomNum);
//                     }
//                 }
//                 ,
//                 error: function() {
//                     alert("error");
//                   }
          
//             });
		window.location.href="./per_info.jsp?"+encodeURIComponent(userType)+"&"+encodeURIComponent(userNo)+"&"+encodeURIComponent(email)+"&"+encodeURIComponent(loginPassword);
        }else{
        	  window.location.href="./com_info.html?"+encodeURIComponent(userType)+"&"+encodeURIComponent(userNo)+"&"+encodeURIComponent(email)+"&"+encodeURIComponent(loginPassword);
        }
    }
</script>



</body>
</html>